package org.open.test.queue.util;

import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;

public class MessageQueue {

	private static MessageQueue instance = null;

	private MessageQueue() {

	}

	public synchronized static MessageQueue getInstance() {
		if (instance == null) {
			instance = new MessageQueue();
		}
		return instance;
	}

	private Queue<Map<String, Object>> queue = new LinkedList<Map<String, Object>>();

	public boolean isEmpty() {
		if (queue.isEmpty()) {
			return true;
		}
		return false;
	}

	public Map<String, Object> poll() {
		synchronized (instance) {
			return this.queue.poll();
		}
	}

	public void add(Map<String, Object> one) {
		synchronized (instance) {
			this.queue.add(one);
		}
	}

}
